<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$page = isset($_POST['page']) ? intval($_POST['page']) : 1;  
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$offset = ($page-1)*$rows;

include "../conecta_mysql.inc";

$rs = mysqli_query($con, "SELECT COUNT(CLI_ID) FROM cliente");  
$row = mysqli_fetch_row($rs);  
$result["total"] = $row[0];  
  
$rs = mysqli_query($con, "SELECT CLI_ID, CLI_NOME, CLI_FANTASIA, CLI_CNPJ_CPF, CLI_TIPO, CLI_IE_RG FROM cliente limit $offset,$rows");  

$items = array();  
while($row = mysqli_fetch_object($rs)){
    array_push($items, $row);
}  
$result["rows"] = $items;  
  
echo json_encode($result);
?>
